home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2002-06-12 | 60.3 KB | 2,195 lines
function settingsDefinition(template, subTemplate, subTemplateText, description, preview, path) { this.lsMaxWidth = 100; this.lsMaxHeight = 100; this.lsWidth = 100; this.lsHeight = 100; this.ptMaxWidth = 100; this.ptMaxHeight = 100; this.ptWidth = 100; this.ptHeight = 100; this.quality = 85; this.template = template; this.subTemplate = subTemplate; this.subTemplateText = subTemplateText; this.description = description; this.preview = preview; this.path = path; this.currentTemplate = ''; this.currentSubTemplate = ''; this.origTemplate = ''; this.origSubTemplate = ''; this.templateSettings = ''; this.titleSet = true; this.titleEnabled = true; this.titleDeleteRow = false; this.borderEnabled = false; this.borderColor = 0; this.borderWidth = 0; this.origBorderColor = 0; this.origBorderWidth = 0; this.spacingEnabled = false; this.horizontalSpacing = 0; this.verticalSpacing = 0; } function imageAttributes() { this.flags = 0; this.width = 0; this.height = 0; this.quality = 0; this.format = 'jpg'; } function imageAttributesEqual(o1, o2) { return o1.flags == o2.flags && o1.width == o2.width && o1.height == o2.height && o1.quality == o2.quality && o1.format == o2.format; } function imageObjectAttributes(displayAttributes, indexAttributes) { this.title = ''; this.description = ''; this.image = ''; this.rotation = 0; this.display = displayAttributes; this.index = indexAttributes; } function imageAttributesToString(o) { return '' + o.flags + ', ' + o.width + ', ' + o.height + ', ' + o.quality + ', ' + o.format; } function imageObjectAttributesToString(o) { return '' + o.title + ', ' + o.description + ', ' + o.image + ', ' + imageAttributesToString(o.displayAttributes) + ', ' + imageAttributesToString(o.indexAttributes); } function copyImageAttributes(f, t) { t.flags = f.flags; t.width = f.width; t.height = f.height; t.quality = f.quality; t.format = f.format; } function copyImageObjectAttributes(f, t) { t.title = f.title; t.description = f.description; t.image = f.image; t.rotation = f.rotation; copyImageAttributes(f.index, t.index); copyImageAttributes(f.display, t.display); } var fDisplayImage = new imageAttributes(); var fIndexImage = new imageAttributes(); var oDisplayImage = new imageAttributes(); var oIndexImage = new imageAttributes(); var fImage = new imageObjectAttributes(fDisplayImage, fIndexImage); var oImage = new imageObjectAttributes(oDisplayImage, oIndexImage); var currentImage; var fIndexSettings; var fDisplaySettings; var currentSettings; var currentTemplateSettings; var INDEX_IS_TABLE = 0x00000001; var INDEX_INCLUDE_TITLE = 0x00000002; var DISPLAY_LAYOUT_MASK = 0x0000000f; var TABLE_GENERATED_MASK = 0x00000800; var numoftabs=3; var currentTab = -1; var numoftabs1=2; var currentTab1 = -1; var initialTab1 = 0; var app = new ActiveXObject( "FSI.FSIApplication" ); var app2 = new ActiveXObject( "FSI.FSIApplication2" ); var theSelection; var theTable; var selection; var indexCatalog; var displayCatalog; var current = 1; var index = -1; var indices = new Array(); var positions = new Array(); var count = 0; var seqChanged = false; var isUpdating = false; var forceUpdate = false; var isValid = false; var fFieldName; var isInitial = window.dialogArguments; var indexModified = false; var displayModified = false; var listInit = false; function ListCtrl_OnSelect() { if (isUpdating || (!forceUpdate && index == FSIListCtrl.Index)) return; updateItem(); updateTab(); } function ListCtrl_OnMove() { isUpdating = true; var from = FSIListCtrl.Index; var to = FSIListCtrl.DropIndex; var f = indices[from]; if (to > from) { for (var i = from; i < to - 1; i++) indices[i] = indices[i + 1]; indices[to - 1] = f; } else { for (var i = from; i > to; i--) indices[i] = indices[i - 1]; indices[to] = f; } index = to; selection.SetIndex(indices[index]); FSIListCtrl.Move(from, to); seqChanged = true; FSIListCtrl.focus(); isUpdating = false; } function ListCtrl_OnReady() { listInit = true; FSIListCtrl.SetSize(ListCtrl.clientWidth - 2, ListCtrl.clientHeight - 2); FSIListCtrl.MoveCursor = true; updateCatalog(); tabshow(initialTab1, false); } function initTemplateCombo(o, path, s) { var iter = new ActiveXObject('FSI.FSIDirIterator'); var index = 0; var i = 0; iter.DefineSearch('.\\PhotoGallery\\' + path, '*'); for (;;) { var p = iter.GetNext(); if (!p.length) break; var q = p.split('.'); if (q.length > 1) { if (q[q.length - 1].split('\\').length == 1) continue; } p = p.split('\\'); p = p[p.length - 1]; if (s == p) index = i; var theOption = document.createElement("OPTION"); o.options.add(theOption); theOption.innerText = p; i++; } o.selectedIndex = index; } function handleInfo(info, settings) { var s = info.split('\n'); for (var i = 0; i < s.length; i++) { var p = s[i].split('='); if (p[0] == 'template') settings.currentTemplate = p[1]; else if (p[0] == 'subtemplate') settings.currentSubTemplate = p[1]; else if (p[0] == 'flags') settings.flags = p[1] - 0; else if (p[0] == 'width') settings.width = p[1] - 0; else if (p[0] == 'height') settings.height = p[1] - 0; else if (p[0] == 'quality') settings.quality = p[1] - 0; else if (p[0] == 'borderColor') settings.borderColor = p[1] - 0; else if (p[0] == 'borderWidth') settings.borderWidth = p[1] - 0; } } function init() { fIndexSettings = new settingsDefinition(template, templateStyle, styleText, indexDescription, indexPreview, 'Thumbnail'); fDisplaySettings = new settingsDefinition(wrapper, wrapperOptions, wrapperOptionsText, displayDescription, displayPreview, 'Photo'); theSelection = app.GetCurrentSelection(); if (!theSelection) return; theTable = theSelection.GetTable(); indexCatalog = theSelection.GetIndexCatalog(); displayCatalog = theSelection.GetDisplayCatalog(); app2.SetDialogTitle('Photo Gallery Properties Editor: ' + theTable.Name); selection = app.GetGlobalSelection1(); if ((indexCatalog.Flags & INDEX_IS_TABLE) || window.dialogArguments) formatType[1].checked = true; else formatType[0].checked = true; handleInfo(indexCatalog.Info, fIndexSettings); fIndexSettings.origTemplate = fIndexSettings.currentTemplate; fIndexSettings.origSubTemplate = fIndexSettings.currentSubTemplate; fIndexSettings.origBorderColor = fIndexSettings.borderColor; fIndexSettings.origBorderWidth = fIndexSettings.borderWidth; handleInfo(displayCatalog.Info, fDisplaySettings); fDisplaySettings.origTemplate = fDisplaySettings.currentTemplate; fDisplaySettings.origSubTemplate = fDisplaySettings.currentSubTemplate; fDisplaySettings.origBorderColor = fDisplaySettings.borderColor; fDisplaySettings.origBorderWidth = fDisplaySettings.borderWidth; initTemplateCombo(template, 'Thumbnail', fIndexSettings.currentTemplate); initTemplateCombo(templateStyle, 'Thumbnail\\' + template.options[template.selectedIndex].innerText + '\\options', fIndexSettings.currentSubTemplate); initTemplateCombo(wrapper, 'Photo', fDisplaySettings.currentTemplate); initTemplateCombo(wrapperOptions, 'Photo\\' + wrapper.options[wrapper.selectedIndex].innerText + '\\options', fDisplaySettings.currentSubTemplate); if (indexCatalog.Settings.length) { updateSettings(indexCatalog.Settings, fIndexSettings); fIndexSettings.lsMaxWidth = indexCatalog.LsMaxWidth; fIndexSettings.lsMaxHeight = indexCatalog.LsMaxHeight; fIndexSettings.lsMinWidth = indexCatalog.LsMinWidth; fIndexSettings.lsMinHeight = indexCatalog.LsMinHeight; fIndexSettings.lsWidth = indexCatalog.LsWidth; fIndexSettings.lsHeight = indexCatalog.LsHeight; fIndexSettings.ptMaxWidth = indexCatalog.PtMaxWidth; fIndexSettings.ptMaxHeight = indexCatalog.PtMaxHeight; fIndexSettings.ptMinWidth = indexCatalog.PtMinWidth; fIndexSettings.ptMinHeight = indexCatalog.PtMinHeight; fIndexSettings.ptWidth = indexCatalog.PtWidth; fIndexSettings.ptHeight = indexCatalog.PtHeight; fIndexSettings.horizontalSpacing = indexCatalog.HorizontalSpacing; fIndexSettings.verticalSpacing = indexCatalog.VerticalSpacing; } else updateInfo(fIndexSettings); if (displayCatalog.Settings.length) { updateSettings(displayCatalog.Settings, fDisplaySettings); fDisplaySettings.lsMaxWidth = displayCatalog.LsMaxWidth; fDisplaySettings.lsMaxHeight = displayCatalog.LsMaxHeight; fDisplaySettings.lsMinWidth = displayCatalog.LsMinWidth; fDisplaySettings.lsMinHeight = displayCatalog.LsMinHeight; fDisplaySettings.lsWidth = displayCatalog.LsWidth; fDisplaySettings.lsHeight = displayCatalog.LsHeight; fDisplaySettings.ptMaxWidth = displayCatalog.PtMaxWidth; fDisplaySettings.ptMaxHeight = displayCatalog.PtMaxHeight; fDisplaySettings.ptMinWidth = displayCatalog.PtMinWidth; fDisplaySettings.ptMinHeight = displayCatalog.PtMinHeight; fDisplaySettings.ptWidth = displayCatalog.PtWidth; fDisplaySettings.ptHeight = displayCatalog.PtHeight; } else updateInfo(fDisplaySettings); updatePreview(fIndexSettings); updatePreview(fDisplaySettings); fIndexSettings.borderColor = fIndexSettings.origBorderColor; fIndexSettings.borderWidth = fIndexSettings.origBorderWidth; fDisplaySettings.borderColor = fDisplaySettings.origBorderColor; fDisplaySettings.borderWidth = fDisplaySettings.origBorderWidth; if (templateStyle.options.length) { colorStyleDiv.className="tabhide"; templateStyleDiv.className="tabshow"; } else { templateStyleDiv.className="tabhide"; if (fIndexSettings.borderEnabled) { colorStyleDiv.className="tabshow"; bordercolorctl.style.backgroundColor = fIndexSettings.borderColor; borderwidth.value = fIndexSettings.borderWidth; } else colorStyleDiv.className="tabhide"; } if (fIndexSettings.spacingEnabled) { cellSpacingDiv.className="tabshow"; cellspacing.value = fIndexSettings.horizontalSpacing; } else cellSpacingDiv.className="tabhide"; if (wrapperOptions.options.length) { displayColorStyleDiv.className="tabhide"; wrapperOptionsDiv.className="tabshow"; } else { wrapperOptionsDiv.className="tabhide"; if (fDisplaySettings.borderEnabled) { displayColorStyleDiv.className="tabshow"; displaybordercolorctl.style.backgroundColor = fDisplaySettings.borderColor; displayborderwidth.value = fDisplaySettings.borderWidth; } else displayColorStyleDiv.className="tabhide"; } fFieldName = theSelection.BannerNameField; titleInBanner.checked = fFieldName.length; updateIndexTab(formatType[1].checked) textLink.value = indexCatalog.Name; columns.selectedIndex = indexCatalog.ColNo - 1; includeTitle.checked = indexCatalog.Flags & INDEX_INCLUDE_TITLE; layoutSelect[displayCatalog.Flags & DISPLAY_LAYOUT_MASK].checked = true; setDialogSize(630, 458); var theMode = app.GetInstVar('mode') - 0; if (window.dialogArguments || (theMode == 1 && (indexCatalog.Flags & INDEX_IS_TABLE) == 0)) theMode = 0; if (theMode < 0) { initialTab1 = 1; theMode = 0; } if (selection) { selection.SetTable(theTable); selection.SetIndex(0); imageNo.innerText = selection.Count(); for (var i = 0; i < selection.Count(); i++) { var pos = selection.GetField('Position') - 0; positions[count] = pos; var p = count; for (var j = 0; j < count; j++) { if (pos < positions[indices[j]]) { p = j; break; } } if (p < count) { for (var j = count; j > p; j--) indices[j] = indices[j - 1]; } indices[p] = i; count++; selection.NextRecord(); } } if (theMode) currentSettings = (currentTab1 ? fDisplaySettings : fIndexSettings); tabshow(theMode, true); if (theMode == 0) FSIListCtrl.focus(); } function newRollover(imgName,imgFiles) { if (document.images) { imgFiles=imgFiles+","; imgNo=1; while(imgFiles.indexOf(',')>0) { imgFile=imgFiles.substring(0,imgFiles.indexOf(',')); imgFiles=imgFiles.substring(imgFiles.indexOf(',')+1,imgFiles.length); eval(imgName+"_urc_"+imgNo+"=new Image();"); eval(imgName+"_urc_"+imgNo+".src='"+imgFile+"';"); imgNo++; } } } function roll(img,on) { eval("document.images['"+img+"'].src="+img+"_urc_"+on+".src;"); } newRollover("tabimg_1b","../resources/images/tab-right-low.gif,../resources/images/tab-left-hi.gif,../resources/images/pix.gif"); for (i=0;i!=numoftabs;i++) { newRollover("tabimg"+i+"a","../resources/images/tab-left-low.gif,../resources/images/tab-right-hi.gif,../resources/images/tab-top-hi.gif"); newRollover("tabimg"+i+"b","../resources/images/tab-right-low.gif,../resources/images/tab-left-hi.gif,../resources/images/tab-top-hi.gif"); } newRollover("tabimg"+numoftabs+"a","../resources/images/tab-left-low.gif,../resources/images/tab-right-hi.gif,../resources/images/pix.gif"); newRollover("tabimg_1b1","../resources/images/tab-right-low.gif,../resources/images/tab-left-hi.gif,../resources/images/pix.gif"); for (i=0;i!=numoftabs1;i++) { newRollover("tabimg1"+i+"a","../resources/images/tab-left-low.gif,../resources/images/tab-right-hi.gif,../resources/images/tab-top-hi.gif"); newRollover("tabimg1"+i+"b","../resources/images/tab-right-low.gif,../resources/images/tab-left-hi.gif,../resources/images/tab-top-hi.gif"); } newRollover("tabimg1"+numoftabs1+"a","../resources/images/tab-left-low.gif,../resources/images/tab-right-hi.gif,../resources/images/pix.gif"); function tabshow(tabnum, maintab) { var tabno = (maintab ? numoftabs : numoftabs1); var s = (maintab ? '' : '1'); var theTab = (maintab ? currentTab : currentTab1); if (maintab && ((currentTab == 1 && fIndexSettings.origTemplate != template.options[template.selectedIndex].innerText) || (currentTab == 2 && fDisplaySettings.origTemplate != wrapper.options[wrapper.selectedIndex].innerText))) { setImageSizeAll(); } if (theTab >= 0) document.all["tabText"+s+theTab].className="tabStyle"; document.all["tabText"+s+tabnum].className="tabStyleHl"; // turn all tabs off roll("tabimg_1b"+s,3); if (maintab) { document.all["tab_1bot"+s].style.backgroundImage="url('../resources/images/tab-bottom.gif')"; currentTemplateSettings = (tabnum ? (tabnum == 2 ? fDisplaySettings : fIndexSettings) : null); } for (i=0;i!=tabno;i++) { roll("tabimg"+s+i+"a",1); roll("tabimg"+s+i+"b",1); document.all["tab"+s+i].style.backgroundImage="url('../resources/images/tab-top-low.gif')"; document.all["tab"+s+i+"bot"].style.backgroundImage="url('../resources/images/tab-bottom.gif')"; if (maintab) document.all["content"+s+i].className="tabhide"; } roll("tabimg"+s+tabno+"a",3); document.all["tab"+s+tabno+"bot"].style.backgroundImage="url('../resources/images/tab-bottom.gif')"; // turn on the right tab now... if (tabnum==0) { roll("tabimg_1b"+s,2); } else { roll("tabimg"+s+(tabnum-1)+"b",2); } roll("tabimg"+s+tabnum+"a",3); roll("tabimg"+s+tabnum+"b",3); roll("tabimg"+s+(tabnum+1)+"a",2); document.all["tab"+s+tabnum].style.backgroundImage="url('../resources/images/tab-top-hi.gif')"; document.all["tab"+s+tabnum+"bot"].style.backgroundImage="url('../resources/images/pix.gif')"; if (maintab) { document.all["content"+s+tabnum].className="tabshow"; currentTab = tabnum; if (currentImage && currentTab == 0 && (currentImage.flags & TABLE_GENERATED_MASK) == 0) updateTab(); } else { getFromTab(); currentTab1 = tabnum; currentImage = (currentTab1 ? fDisplayImage : fIndexImage); currentSettings = (currentTab1 ? fDisplaySettings : fIndexSettings); updateTab(); } } function setImageType() { if (imageType.selectedIndex) { jpeg.className="tabhide"; gif.className="tabshow"; prop.innerText = 'Palette:'; FSIImage.Quality = colors.selectedIndex + 1; FSIImage.Format = 'gif'; FSIImage.Palette = palette.selectedIndex; } else { gif.className="tabhide"; jpeg.className="tabshow"; prop.innerText = 'Quality:'; FSIImage.Quality = quality.value - 0; FSIImage.Format = 'jpg'; FSIImage.Palette = 0; } displayImage(); } function setPalette() { FSIImage.Palette = palette.selectedIndex; displayImage(); } function setColors() { FSIImage.Quality = colors.selectedIndex + 1; displayImage(); } function getFileName() { var theName = selection.GetField('Image'); theName = theName.split('\\'); return theName[theName.length - 1]; } function updateCatalog() { var column0 = app.GetSystemVar('nof_photoNameSize') - 0; var column1 = app.GetSystemVar('nof_photoTitleSize') - 0; var speed = app.GetSystemVar('nof_downloadSpeed') - 0; if (!column0 || !column1) { column0 = 92; column1 = 135; speed = 1; } downloadSpeed.selectedIndex = speed; FSIListCtrl.AddColumn('File Name', column0); FSIListCtrl.AddColumn('Title', column1); if (selection) { for (var i = 0; i < count; i++) { selection.SetIndex(indices[i]); var row = FSIListCtrl.AddRow(getFileName()); FSIListCtrl.SetValue(row, 1, selection.GetField('Title')); } if (count) { FSIListCtrl.Index = app.IntArg; selection.SetIndex(indices[app.IntArg]); updateItem(); } else { DeleteItem.disabled = true; DeleteAll.disabled = true; } } } function updateIndex() { fIndexSettings.origTemplate = fIndexSettings.currentTemplate; fIndexSettings.origSubTemplate = fIndexSettings.currentSubTemplate; indexCatalog.Info = 'length=' + fIndexSettings.length + '\n' + 'index=' + fIndexSettings.index + '\n' + 'flags=' + fIndexSettings.flags + '\n' + 'width=' + fIndexSettings.width + '\n' + 'height=' + fIndexSettings.height + '\n' + 'quality=' + fIndexSettings.quality + '\n' + 'template=' + fIndexSettings.currentTemplate + '\n' + 'subtemplate=' + fIndexSettings.currentSubTemplate + '\n' + 'borderColor=' + fIndexSettings.borderColor + '\n' + 'borderWidth=' + fIndexSettings.borderWidth; indexCatalog.Settings = fIndexSettings.templateSettings; indexCatalog.LsMaxWidth = fIndexSettings.lsMaxWidth; indexCatalog.LsMaxHeight = fIndexSettings.lsMaxHeight; indexCatalog.LsMinWidth = fIndexSettings.lsMinWidth; indexCatalog.LsMinHeight = fIndexSettings.lsMinHeight; indexCatalog.LsWidth = fIndexSettings.lsWidth; indexCatalog.LsHeight = fIndexSettings.lsHeight; indexCatalog.PtMaxWidth = fIndexSettings.ptMaxWidth; indexCatalog.PtMaxHeight = fIndexSettings.ptMaxHeight; indexCatalog.PtMinWidth = fIndexSettings.ptMinWidth; indexCatalog.PtMinHeight = fIndexSettings.ptMinHeight; indexCatalog.PtWidth = fIndexSettings.ptWidth; indexCatalog.PtHeight = fIndexSettings.ptHeight; indexCatalog.HorizontalSpacing = fIndexSettings.horizontalSpacing; indexCatalog.VerticalSpacing = fIndexSettings.verticalSpacing; } function checkUpdateIndex() { if (formatType[1].checked && ((indexCatalog.Flags & INDEX_IS_TABLE) == 0 || fIndexSettings.origTemplate != fIndexSettings.currentTemplate || fIndexSettings.origSubTemplate != fIndexSettings.currentSubTemplate || ((indexCatalog.Flags & INDEX_INCLUDE_TITLE) != 0) != includeTitle.checked) || fIndexSettings.horizontalSpacing != indexCatalog.HorizontalSpacing || fIndexSettings.verticalSpacing != indexCatalog.VerticalSpacing || fIndexSettings.borderColor != fIndexSettings.origBorderColor || fIndexSettings.borderWidth != fIndexSettings.origBorderWidth) { indexModified = true; updateIndex(); importIndexTable(fIndexSettings.origTemplate != fIndexSettings.currentTemplate || isInitial); } var flags = indexCatalog.Flags; if (formatType[1].checked) flags |= INDEX_IS_TABLE; else flags &= ~INDEX_IS_TABLE; if (includeTitle.checked) flags |= INDEX_INCLUDE_TITLE; else flags &= ~INDEX_INCLUDE_TITLE; if (indexCatalog.Flags != flags) { indexModified = true; indexCatalog.Flags = flags; } } function updateDisplay() { displayModified = true; fDisplaySettings.origTemplate = fDisplaySettings.currentTemplate; fDisplaySettings.origSubTemplate = fDisplaySettings.currentSubTemplate; displayCatalog.Info = 'length=' + fDisplaySettings.length + '\n' + 'index=' + fDisplaySettings.index + '\n' + 'flags=' + fDisplaySettings.flags + '\n' + 'width=' + fDisplaySettings.width + '\n' + 'height=' + fDisplaySettings.height + '\n' + 'quality=' + fDisplaySettings.quality + '\n' + 'template=' + fDisplaySettings.currentTemplate + '\n' + 'subtemplate=' + fDisplaySettings.currentSubTemplate + '\n' + 'borderColor=' + fDisplaySettings.borderColor + '\n' + 'borderWidth=' + fDisplaySettings.borderWidth; displayCatalog.Settings = fDisplaySettings.templateSettings; displayCatalog.LsMaxWidth = fDisplaySettings.lsMaxWidth; displayCatalog.LsMaxHeight = fDisplaySettings.lsMaxHeight; displayCatalog.LsMinWidth = fDisplaySettings.lsMinWidth; displayCatalog.LsMinHeight = fDisplaySettings.lsMinHeight; displayCatalog.LsWidth = fDisplaySettings.lsWidth; displayCatalog.LsHeight = fDisplaySettings.lsHeight; displayCatalog.PtMaxWidth = fDisplaySettings.ptMaxWidth; displayCatalog.PtMaxHeight = fDisplaySettings.ptMaxHeight; displayCatalog.PtMinWidth = fDisplaySettings.ptMinWidth; displayCatalog.PtMinHeight = fDisplaySettings.ptMinHeight; displayCatalog.PtWidth = fDisplaySettings.ptWidth; displayCatalog.PtHeight = fDisplaySettings.ptHeight; } function checkUpdateDisplay() { if (fDisplaySettings.origTemplate != fDisplaySettings.currentTemplate || fDisplaySettings.origSubTemplate != fDisplaySettings.currentSubTemplate || fDisplaySettings.borderColor != fDisplaySettings.origBorderColor || fDisplaySettings.borderWidth != fDisplaySettings.origBorderWidth || isInitial) { displayModified = true; updateDisplay(); importDisplayTable(); } var theLayoutId = 0; for (var i = 0; i < 7; i++) { if (layoutSelect[i].checked) { theLayoutId = i; break; } } if ((displayCatalog.Flags & DISPLAY_LAYOUT_MASK) != theLayoutId || isInitial) { displayModified = true; var path = wrapper.options[wrapper.selectedIndex].innerText; var importer = new ActiveXObject('FSI.FSIImporter'); if (!importer.StartImport('.\\PhotoGallery\\Layout\\layout' + theLayoutId, true)) return; importer.OpenFile('index.html', false); if (importer.NextTag('BODY')) { importer.DeleteAttribute('BGCOLOR'); importer.DeleteAttribute('BACKGROUND'); importer.DeleteAttribute('TEXT'); importer.DeleteAttribute('LINK'); importer.DeleteAttribute('VLINK'); importer.DeleteAttribute('ALINK'); } importer.CloseFile(); importer.ImportObject('index.html', displayCatalog, 3, true); importer.DeleteImportDirectory(); flags = displayCatalog.Flags; flags &= ~DISPLAY_LAYOUT_MASK; flags |= theLayoutId; displayCatalog.Flags = flags; } isInitial = false; } function onClose() { if (currentTab == 1 && fIndexSettings.origTemplate != template.options[template.selectedIndex].innerText) { indexModified = true; setImageSizeAll(); } if (currentTab == 2 && fDisplaySettings.origTemplate != wrapper.options[wrapper.selectedIndex].innerText) { displayModified = true; setImageSizeAll(); } save(); fIndexSettings.currentTemplate = template.options[template.selectedIndex].innerText; fIndexSettings.currentSubTemplate = (templateStyle.selectedIndex != -1 ? templateStyle.options[templateStyle.selectedIndex].innerText : ''); fDisplaySettings.currentTemplate = wrapper.options[wrapper.selectedIndex].innerText; fDisplaySettings.currentSubTemplate = (wrapperOptions.selectedIndex != -1 ? wrapperOptions.options[wrapperOptions.selectedIndex].innerText : ''); checkUpdateIndex(); checkUpdateDisplay(); var fieldName = ''; if (titleInBanner.checked) fieldName = 'Title'; if (fieldName != fFieldName) { displayModified = true; theSelection.BannerNameField = fieldName; } if (indexCatalog.Name != textLink.value) { indexCatalog.Name = textLink.value; indexModified = true; } if (indexCatalog.ColNo != columns.selectedIndex + 1) { indexModified = true; indexCatalog.ColNo = columns.selectedIndex + 1; } if (seqChanged) { indexModified = true; for (var i = 0; i < count; i++) { selection.SetIndex(indices[i]); selection.SetField('Position', i); selection.Update(); } } var flags = 0; if (indexModified) flags += 1; if (displayModified) flags += 2; app.IntArg = flags; if (listInit) { app.SetSystemVar('nof_photoNameSize', FSIListCtrl.GetColumnWidth(0)); app.SetSystemVar('nof_photoTitleSize', FSIListCtrl.GetColumnWidth(1)); } app.SetSystemVar('nof_downloadSpeed', downloadSpeed.selectedIndex); } function add() { var s = app2.SelectMultipleFiles(''); if (s.length) { s = s.split('|'); var position = count; for (var i = 0; i < s.length; i++) { var path = s[i]; var quality; var tnquality; selection.NewRecord(); selection.SetField('Position', count); selection.SetField('Image', path); selection.SetField('ImageFlags', 0); selection.SetField('ImageTnFlags', 0); path = path.split('.'); if (path.length == 2) { path = path[1].toLowerCase(); if (path == 'jpg' || path == 'jpeg') { quality = fDisplaySettings.quality; tnquality = fIndexSettings.quality; } else if (path == 'gif') { quality = 7; tnquality = 7; } else { path = 'jpg'; quality = fDisplaySettings.quality; tnquality = fIndexSettings.quality; } } else { path = 'jpg'; quality = fDisplaySettings.quality; tnquality = fIndexSettings.quality; } selection.SetField('ImageQuality', quality); selection.SetField('ImageTnQuality', tnquality); selection.SetField('ImageFormat', path); selection.SetField('ImageTnFormat', path); selection.Update(); var row = FSIListCtrl.AddRow(getFileName()); FSIListCtrl.SetValue(row, 1, selection.GetField('Title')); indices[count] = count; count++; } DeleteItem.disabled = (count == 0); DeleteAll.disabled = (count == 0); if (position) selection.SetIndex(indices[FSIListCtrl.Index]); FSIListCtrl.Index = position; FSIListCtrl.focus(); imageNo.innerText = selection.Count(); } } function deleteItem() { getFromTab(); if ((fDisplayImage.flags & TABLE_GENERATED_MASK) != 0) theSelection.FreeKey(fImage.image, fDisplayImage.width, fDisplayImage.height, fImage.rotation, fDisplayImage.quality, fDisplayImage.format); if ((fIndexImage.flags & TABLE_GENERATED_MASK) != 0) theSelection.FreeKey(fImage.image, fIndexImage.width, fIndexImage.height, fImage.rotation, fIndexImage.quality, fIndexImage.format); isUpdating = true; index = FSIListCtrl.Index; selection.SetIndex(indices[index]); selection.DeleteRecord(); selection.Update(); FSIListCtrl.Delete(); var removedIndex = indices[index]; for (var i = index; i < count - 1; i++) indices[i] = indices[i + 1]; for (var i = 0; i < count - 1; i++) { if (indices[i] > removedIndex) indices[i]--; } if (index == selection.Count()) index--; FSIListCtrl.Index = index; count--; seqChanged = true; if (!count) { DeleteItem.disabled = true; DeleteAll.disabled = true; } imageNo.innerText = selection.Count(); FSIListCtrl.focus(); isUpdating = false; isValid = false; forceUpdate = true; updateItem(); updateTab(); } function deleteAll() { if (!warning('Are you sure you want to remove all the images from the gallery?', 'question', 'nof_qpgremoveall')) return; getFromTab(); isUpdating = true; FSIListCtrl.Index = 0; for (var i = count - 1; i >= 0; i--) { selection.SetIndex(index); var image = selection.GetField('Image'); var displayflags = selection.GetField('ImageFlags') - 0; var displaywidth = selection.GetField('ImageWidth') - 0; var displayheight = selection.GetField('ImageHeight') - 0; var rotation = selection.GetField('ImageRotation') - 0; var displayquality = selection.GetField('ImageQuality') - 0; var displayformat = selection.GetField('ImageFormat'); var indexflags = selection.GetField('ImageTnFlags') - 0; var indexwidth = selection.GetField('ImageTnWidth') - 0; var indexheight = selection.GetField('ImageTnHeight') - 0; var indexquality = selection.GetField('ImageTnQuality') - 0; var indexformat = selection.GetField('ImageTnFormat'); if ((displayflags & TABLE_GENERATED_MASK) != 0) theSelection.FreeKey(image, displaywidth, displayheight, rotation, displayquality, displayformat); if ((indexflags & TABLE_GENERATED_MASK) != 0) theSelection.FreeKey(image, indexwidth, indexheight, rotation, indexquality, indexformat); selection.DeleteRecord(); selection.Update(); FSIListCtrl.Delete(); } seqChanged = true; DeleteItem.disabled = true; DeleteAll.disabled = true; index = -1; count = 0; imageNo.innerText = 0; FSIListCtrl.focus(); isUpdating = false; isValid = false; forceUpdate = true; updateItem(); updateTab(); } function orientationToValue(i) { switch (i) { case 0: return 0; case 1: return 90; case 2: return 270; default: return 180; } } function orientationToIndex(v) { switch (v - 0) { case 0: return 0; case 90: return 1; case 270: return 2; default: return 3; } } function getFromTab() { if (isValid && currentTab1 >= 0) { var theFlags = 0; currentImage.flags = (currentImage.flags & 0xffffff00) | theFlags; currentImage.quality = quality.value - 0; currentImage.format = (imageType.selectedIndex ? 'gif' : 'jpg'); if (imageType.selectedIndex) currentImage.quality = colors.selectedIndex + 1 + 0x10000 * palette.selectedIndex; } } function updateTab() { if (isValid && currentTab1 >= 0) { FSIImage.SwitchImage(); var updating = isUpdating; isUpdating = true; var theFlags = currentImage.flags; var isCreated = (theFlags & TABLE_GENERATED_MASK) != 0; FSIImage.IsCreated = isCreated; quality.value = currentImage.quality; updateQuality(); imageType.selectedIndex = (currentImage.format == 'gif' ? 1 : 0); if (imageType.selectedIndex) { jpeg.className="tabhide"; gif.className="tabshow"; prop.innerText = 'Palette:'; palette.selectedIndex = (currentImage.quality & 0xffff0000) / 0x10000; if (!isCreated && !currentImage.quality) currentImage.quality = FSIImage.Depth - 1; colors.selectedIndex = (currentImage.quality & 0xffff) - 1; FSIImage.Quality = colors.selectedIndex + 1; FSIImage.Format = 'gif'; FSIImage.Palette = palette.selectedIndex; } else { gif.className="tabhide"; jpeg.className="tabshow"; prop.innerText = 'Quality:'; FSIImage.Quality = quality.value - 0; FSIImage.Format = 'jpg'; } if (!isCreated) { currentImage.flags |= TABLE_GENERATED_MASK; updateSize(); } FSIImage.Width = currentImage.width; FSIImage.Height = currentImage.height; FSIImage.Rotation = orientationToValue(orientation.selectedIndex); isUpdating = updating; displayImage(); } } function save() { if (isValid) { var titleIschanged = fImage.title != title.value; var descriptionIsChanged = fImage.description != description.value; fImage.title = title.value; fImage.description = description.value; fImage.rotation = orientationToValue(orientation.selectedIndex); getFromTab(); if (titleIschanged) { selection.SetField('Title', fImage.title); FSIListCtrl.SetValue(index, 1, title.value); indexModified = true; displayModified = true; } if (descriptionIsChanged) { selection.SetField('Description', fImage.description); displayModified = true; } if (oImage.rotation != fImage.rotation) { selection.SetField('ImageRotation', fImage.rotation); indexModified = true; displayModified = true; } if (!imageAttributesEqual(oImage.display, fImage.display)) { selection.SetField('ImageFlags', fImage.display.flags); selection.SetField('ImageWidth', fImage.display.width); selection.SetField('ImageHeight', fImage.display.height); selection.SetField('ImageQuality', fImage.display.quality); selection.SetField('ImageFormat', fImage.display.format); displayModified = true; } if (!imageAttributesEqual(oImage.index, fImage.index)) { selection.SetField('ImageTnFlags', fImage.index.flags); selection.SetField('ImageTnWidth', fImage.index.width); selection.SetField('ImageTnHeight', fImage.index.height); selection.SetField('ImageTnQuality', fImage.index.quality); selection.SetField('ImageTnFormat', fImage.index.format); indexModified = true; } } } function updateItem() { if (isUpdating) return; if (!forceUpdate && index == FSIListCtrl.Index) return; forceUpdate = false; isUpdating = true; if (count == 0) { title.value = ''; description.value = ''; orientation.selectedIndex = 0; quality.value = 100; updateQuality(); FSIImage.Unload(); displayImage(); isValid = false; isUpdating = false; return; } save(); index = FSIListCtrl.Index; selection.SetIndex(indices[index]); fImage.title = selection.GetField('Title'); fImage.description = selection.GetField('Description'); fImage.image = selection.GetField('Image'); fImage.display.flags = selection.GetField('ImageFlags') - 0; fImage.display.width = selection.GetField('ImageWidth') - 0; fImage.display.height = selection.GetField('ImageHeight') - 0; fImage.rotation = selection.GetField('ImageRotation') - 0; fImage.display.quality = selection.GetField('ImageQuality') - 0; fImage.display.format = selection.GetField('ImageFormat'); fImage.index.flags = selection.GetField('ImageTnFlags') - 0; fImage.index.width = selection.GetField('ImageTnWidth') - 0; fImage.index.height = selection.GetField('ImageTnHeight') - 0; fImage.index.quality = selection.GetField('ImageTnQuality') - 0; fImage.index.format = selection.GetField('ImageTnFormat'); copyImageObjectAttributes(fImage, oImage); title.value = fImage.title; description.value = fImage.description; orientation.selectedIndex = orientationToIndex(fImage.rotation); FSIImage.Load(fImage.image); isValid = true; isUpdating = false; } function displayImage() { if (isUpdating ) return; FSIImage.Display(); var w = currentImage.width; var h = currentImage.height; if (w > FSIImage.clientWidth || h > FSIImage.clientHeight) { var ratiox = FSIImage.clientWidth / w; var ratioy = FSIImage.clientHeight / h; var ratio = (ratiox < ratioy ? ratiox : ratioy); ratio = toint(100 * ratio + 0.5); if (ratio < 1) ratio = 1; else if (ratio > 99) ratio = 99; previewScale.innerText = '(scaled to ' + ratio + '% to fit)'; } else previewScale.innerText = '(actual size)'; var theSize = FSIImage.FileSize; var units = ''; if (theSize > 1024) { theSize = theSize / 1024; units = ' KB'; } if (theSize > 1024) { theSize = theSize / 1024; units = ' MB'; } if (units.length) { theSize = '' + theSize; var s = theSize.split('.'); theSize = s[0] + '.'; if (s.length > 1) theSize += s[1].substr(0, 1); else theSize += '0'; } fileSize.innerText = 'File Size: ' + theSize + units; updateDownload(); } function updateDownload() { var theSize = FSIImage.FileSize; var s; switch (downloadSpeed.selectedIndex) { case 0: s = 28800; break; case 1: s = 56600; break; case 2: s = 128000; break; case 3: s = 384000; break; case 4: s = 512000; break; default: s = 1540000; break; } var t = '' + theSize * 12 / s; t = t.split('.'); if (t.length == 1 || t[0].length > 1) t = t[0]; else t = t[0] + '.' + t[1].substr(0, 1); if (t == '0.0') t = '0.1'; downloadTime.innerText = t; } function spin(o, v, f) { o.value = o.value - 0 + v; f(); } function toint(i) { var s = '' + i; return s.split('.')[0] - 0; } function calcProportional() { var w = FSIImage.OrigWidth; var h = FSIImage.OrigHeight; if (orientation.selectedIndex == 1 || orientation.selectedIndex == 2) { var i = w; w = h; h = i; } var maxWidth = currentSettings.lsWidth; var maxHeight = currentSettings.lsHeight; if (w < h && currentSettings.ptWidth && currentSettings.ptHeight) { maxWidth = currentSettings.ptWidth; maxHeight = currentSettings.ptHeight; } var wscale = toint(1000 * w / maxWidth); var hscale = toint(1000 * h / maxHeight); var scale = (wscale > hscale) ? wscale : hscale; if (scale) { currentImage.width = toint(1000 * w / scale); currentImage.height = toint(1000 * h / scale); } else { currentImage.width = 0; currentImage.height = 0; } } function updateSize() { calcProportional(); FSIImage.Width = currentImage.width; FSIImage.Height = currentImage.height; displayImage(); } function updateQuality() { var q = quality.value - 0; if (isNaN(q)) { q = 100; quality.value = q; } else if (q < 0 || q > 100) { if (q < 0) q = 0; else q = 100; quality.value = q; } FSIImage.Quality = q; displayImage(); var i = 3; if (q < 40) i = 0; else if (q < 76) i = 1; else if (q < 100) i = 2; if (qualityLevel.selectedIndex != i) qualityLevel.selectedIndex = i; } function setQuality() { var q = 100; switch (qualityLevel.selectedIndex) { case 0: q = 39; break; case 1: q = 75; break; case 2: q = 99; break; default: q = 100; break; } if (quality.value != q) { quality.value = q; updateQuality(); } } function setOrientation() { // Clear out information for the other image. var otherImage = (currentTab1 ? fIndexImage : fDisplayImage); var theFlags = otherImage.flags; if ((otherImage.flags & TABLE_GENERATED_MASK) != 0) { theSelection.FreeKey(fImage.image, otherImage.width, otherImage.height, fImage.rotation, otherImage.quality, otherImage.format); otherImage.flags &= ~TABLE_GENERATED_MASK; } fImage.rotation = orientationToValue(orientation.selectedIndex); FSIImage.Rotation = fImage.rotation; updateSize() } function moveUp() { if (count < 2) return; isUpdating = true; index = FSIListCtrl.Index; var i = indices[index]; if (index > 0) { indices[index] = indices[index - 1]; indices[index - 1] = i; index--; } else { for (var j = 1; j < count; j++) indices[j - 1] = indices[j]; indices[count - 1] = i; index = count - 1; } selection.SetIndex(indices[index]); FSIListCtrl.MoveUp(); seqChanged = true; FSIListCtrl.focus(); isUpdating = false; } function moveDown() { if (count < 2) return; isUpdating = true; index = FSIListCtrl.Index; var i = indices[index]; if (index < count - 1) { indices[index] = indices[index + 1]; indices[index + 1] = i; index++; } else { for (var j = count - 1; j > 0; j--) indices[j] = indices[j - 1]; indices[0] = i; index = 0; } FSIListCtrl.MoveDown(); seqChanged = true; FSIListCtrl.focus(); isUpdating = false; } function selectLayout(i) { layoutSelect[i].click(); } function updateIndexTab(isTable) { textLink.disabled = isTable; template.disabled = !isTable; templateStyle.disabled = !isTable; columns.disabled = !isTable; includeTitle.disabled = !fIndexSettings.titleEnabled || !isTable; includeTitleText.disabled = !fIndexSettings.titleEnabled || !isTable; indexFormatTitle.disabled = !fIndexSettings.titleEnabled || !isTable; borderwidth.disabled = !isTable; borderwidthup.disabled = !isTable; borderwidthdown.disabled = !isTable; bordercolorctl.disabled = !isTable; cellspacing.disabled = !isTable; cellspacingup.disabled = !isTable; cellspacingdown.disabled = !isTable; if (fIndexSettings.titleEnabled) { includeTitle.style.visibility = 'visible'; includeTitleText.style.visibility = 'visible'; indexFormatTitle.style.visibility = 'visible'; indexFormatTitleHelp.style.visibility = 'visible'; } else { includeTitle.style.visibility = 'hidden'; includeTitleText.style.visibility = 'hidden'; indexFormatTitle.style.visibility = 'hidden'; indexFormatTitleHelp.style.visibility = 'hidden'; } } function importIndexTable(overwriteFormat) { var path = template.options[template.selectedIndex].innerText; var importer = new ActiveXObject('FSI.FSIImporter'); importer.StartImport('.\\PhotoGallery\\Spacer', true); if (!importer.AddFiles('.\\PhotoGallery\\Thumbnail\\' + path + '\\content', true)) return; if (templateStyle.selectedIndex >= 0) { path += '\\options\\' + templateStyle.options[templateStyle.selectedIndex].innerText + '\\content'; if (!importer.AddFiles('.\\PhotoGallery\\Thumbnail\\' + path, true)) return; } for (var i = 0; i < 2; i++) { var filename; if (i == 0) filename = 'index.html'; else filename = 'portrait.html'; if (importer.OpenFile(filename, false)) { if (!includeTitle.checked || fIndexSettings.borderEnabled) { if (!includeTitle.checked && importer.NextId('NOFTitle')) { var removed = false; if (fIndexSettings.titleDeleteRow) { if (importer.PrevTag('TR') && importer.PrevTag('TR')) { var s = importer.OuterHTML; var l = s.length; var del = ''; for (var i = 0; i < l; i++) { if (s.charCodeAt(i) != 13 && s.charCodeAt(i) != 10) del += s.charAt(i); } for (;;) { if (importer.PrevTag('TABLE')) { var s = importer.InnerHTML; var l = s.length; var content = ''; for (var i = 0; i < l; i++) { if (s.charCodeAt(i) != 13 && s.charCodeAt(i) != 10) content += s.charAt(i); } var i = content.search(del); if (i != -1) { content = content.substr(0, i) + content.substr(i + del.length); importer.OuterHTML = content; removed = true; break; } } else break; } } } if (!removed) { importer.First(); if (importer.NextId('NOFTitle')) importer.OuterHTML = '<img height=1 width=1 src="./spacer.gif" vspace=0 hspace=0 border=0>'; } } if (fIndexSettings.borderEnabled && importer.First() && importer.NextId('PhotoTable')) { importer.SetAttribute('border', fIndexSettings.borderWidth); importer.SetAttribute('bordercolor', fIndexSettings.borderColor); } importer.First(); } if (importer.NextTag('BODY')) { importer.DeleteAttribute('BGCOLOR'); importer.DeleteAttribute('BACKGROUND'); importer.DeleteAttribute('TEXT'); importer.DeleteAttribute('LINK'); importer.DeleteAttribute('VLINK'); importer.DeleteAttribute('ALINK'); } importer.CloseFile(); } } importer.ImportObject('index.html', indexCatalog, 1, overwriteFormat); importer.ImportObject('portrait.html', indexCatalog, 2, false); importer.DeleteImportDirectory(); } function importDisplayTable() { var path = wrapper.options[wrapper.selectedIndex].innerText; var importer = new ActiveXObject('FSI.FSIImporter'); if (!importer.StartImport('.\\PhotoGallery\\Photo\\' + path + '\\content', true)) return; if (wrapperOptions.selectedIndex >= 0) { path += '\\options\\' + wrapperOptions.options[wrapperOptions.selectedIndex].innerText + '\\content'; if (!importer.AddFiles('.\\PhotoGallery\\Photo\\' + path, true)) return; } var importDir = importer.GetImportDirectory(false) + '\\'; if (app.DoesFileExist(importDir + 'NavLeft.gif')) displayCatalog.SetFile(1, importDir + 'NavLeft.gif'); if (app.DoesFileExist(importDir + 'NavUp.gif')) displayCatalog.SetFile(2, importDir + 'NavUp.gif'); if (app.DoesFileExist(importDir + 'NavRight.gif')) displayCatalog.SetFile(3, importDir + 'NavRight.gif'); for (var i = 0; i < 2; i++) { var filename; if (i == 0) filename = 'index.html'; else filename = 'portrait.html'; if (importer.OpenFile(filename, false)) { if (fDisplaySettings.borderEnabled) { if (importer.NextId('PhotoTable')) { importer.SetAttribute('border', fDisplaySettings.borderWidth); importer.SetAttribute('bordercolor', fDisplaySettings.borderColor); } importer.First(); } if (importer.NextTag('BODY')) { importer.DeleteAttribute('BGCOLOR'); importer.DeleteAttribute('BACKGROUND'); importer.DeleteAttribute('TEXT'); importer.DeleteAttribute('LINK'); importer.DeleteAttribute('VLINK'); importer.DeleteAttribute('ALINK'); } importer.CloseFile(); } } importer.ImportObject('index.html', displayCatalog, 1, false); importer.ImportObject('portrait.html', displayCatalog, 2, false); importer.DeleteImportDirectory(); } function updateTemplate() { for (var i = currentTemplateSettings.subTemplate.options.length - 1; i >= 0; i--) currentTemplateSettings.subTemplate.options.remove(i); initTemplateCombo(currentTemplateSettings.subTemplate, currentTemplateSettings.path + '\\' + currentTemplateSettings.template.options[currentTemplateSettings.template.selectedIndex].innerText + '\\options', ''); currentTemplateSettings.currentTemplate = currentTemplateSettings.template.options[currentTemplateSettings.template.selectedIndex].innerText; currentTemplateSettings.currentSubTemplate = (currentTemplateSettings.subTemplate.options.length ? currentTemplateSettings.subTemplate.options[currentTemplateSettings.subTemplate.selectedIndex].innerText : ''); updateStyle(currentTemplateSettings); if (currentTemplateSettings == fIndexSettings) { if (currentTemplateSettings.subTemplate.options.length) templateStyleDiv.className="tabshow"; else templateStyleDiv.className="tabhide"; includeTitle.disabled = !fIndexSettings.titleEnabled; includeTitleText.disabled = !fIndexSettings.titleEnabled; includeTitle.checked = fIndexSettings.titleSet; indexFormatTitle.disabled = !fIndexSettings.titleEnabled; if (fIndexSettings.titleEnabled) { includeTitle.style.visibility = 'visible'; includeTitleText.style.visibility = 'visible'; indexFormatTitle.style.visibility = 'visible'; indexFormatTitleHelp.style.visibility = 'visible'; } else { includeTitle.style.visibility = 'hidden'; includeTitleText.style.visibility = 'hidden'; indexFormatTitle.style.visibility = 'hidden'; indexFormatTitleHelp.style.visibility = 'hidden'; } if (!currentTemplateSettings.subTemplate.options.length) { if (fIndexSettings.borderEnabled) { colorStyleDiv.className="tabshow"; bordercolorctl.style.backgroundColor = fIndexSettings.borderColor; borderwidth.value = fIndexSettings.borderWidth; } else colorStyleDiv.className="tabhide"; } else colorStyleDiv.className="tabhide"; if (fIndexSettings.spacingEnabled) { cellSpacingDiv.className="tabshow"; cellspacing.value = fIndexSettings.horizontalSpacing; } else cellSpacingDiv.className="tabhide"; } if (currentTemplateSettings == fDisplaySettings) { if (wrapperOptions.options.length) { displayColorStyleDiv.className="tabhide"; wrapperOptionsDiv.className="tabshow"; } else { wrapperOptionsDiv.className="tabhide"; if (fDisplaySettings.borderEnabled) { displayColorStyleDiv.className="tabshow"; displaybordercolorctl.style.backgroundColor = fDisplaySettings.borderColor; displayborderwidth.value = fDisplaySettings.borderWidth; } else displayColorStyleDiv.className="tabhide"; } } if (currentTemplateSettings.subTemplate.options.length) currentTemplateSettings.subTemplate.selectedIndex = 0; } function updateStyle(settings) { updateInfo(settings); updatePreview(settings); } function updateInfo(settings) { var path = './PhotoGallery/' + settings.path + '/' + settings.template.options[settings.template.selectedIndex].innerText; var optpath = settings.subTemplate.selectedIndex >= 0 ? '/options/' + settings.subTemplate.options[settings.subTemplate.selectedIndex].innerText : ''; if (app.DoesFileExist(path + optpath + '/info.txt')) updateSettings(app2.ReadFile(path + optpath + '/info.txt'), settings); else updateSettings(app2.ReadFile(path + '/info.txt'), settings); } function updatePreview(settings) { var path = settings.path + '/' + settings.template.options[settings.template.selectedIndex].innerText + (settings.subTemplate.selectedIndex >= 0 ? '/options/' + settings.subTemplate.options[settings.subTemplate.selectedIndex].innerText : '') + '/preview.jpg'; settings.preview.src = (app.DoesFileExist('./PhotoGallery/' + path) ? './' + path : './../resources/images/clearpixel.gif'); } function updateSettings(s, settings) { var description = ''; settings.templateSettings = s; settings.titleSet = true; settings.titleEnabled = true; settings.titleDeleteRow = false; settings.lsMaxWidth = 2048; settings.lsMaxHeight = 2048; settings.lsMinWidth = 0; settings.lsMinHeight = 0; settings.lsWidth = 0; settings.lsHeight = 0; settings.ptMaxWidth = 0; settings.ptMaxHeight = 0; settings.ptMinWidth = 0; settings.ptMinHeight = 0; settings.ptWidth = 0; settings.ptHeight = 0; settings.borderEnabled = false; settings.borderColor = 0; settings.borderWidth = 0; settings.spacingEnabled = false; settings.horizontalSpacing = 0; settings.verticalSpacing = 0; s = s.split('\n'); for (var i = 0; i < s.length; i++) { var p = s[i].split(','); if (p[0] == 'description') { description = ''; if (p.length > 1) description = p[1]; for (var j = 2; j < p.length; j++) description += ',' + p[j]; } else if (p[0] == 'landscape') { var maxWidth = 2048; var maxHeight = 2048; var minWidth = 0; var minHeight = 0; var width = 0; var height = 0; for (var j = 1; j < p.length; j++) { var size = p[j].split('='); if (size.length != 2) continue; if (size[0] == 'maxwidth') maxWidth = size[1] - 0; else if (size[0] == 'maxheight') maxHeight = size[1] - 0; else if (size[0] == 'minwidth') minWidth = size[1] - 0; else if (size[0] == 'minheight') minHeight = size[1] - 0; else if (size[0] == 'width') width = size[1] - 0; else if (size[0] == 'height') height = size[1] - 0; } settings.lsMaxWidth = maxWidth; settings.lsMaxHeight = maxHeight; settings.lsMinWidth = minWidth; settings.lsMinHeight = minHeight; settings.lsWidth = width; settings.lsHeight = height; } else if (p[0] == 'portrait') { var maxWidth = 2048; var maxHeight = 2048; var minWidth = 0; var minHeight = 0; var width = 0; var height = 0; for (var j = 1; j < p.length; j++) { var size = p[j].split('='); if (size.length != 2) continue; if (size[0] == 'maxwidth') maxWidth = size[1] - 0; else if (size[0] == 'maxheight') maxHeight = size[1] - 0; else if (size[0] == 'minwidth') minWidth = size[1] - 0; else if (size[0] == 'minheight') minHeight = size[1] - 0; else if (size[0] == 'width') width = size[1] - 0; else if (size[0] == 'height') height = size[1] - 0; } settings.ptMaxWidth = maxWidth; settings.ptMaxHeight = maxHeight; settings.ptMinWidth = minWidth; settings.ptMinHeight = minHeight; settings.ptWidth = width; settings.ptHeight = height; } else if (p[0] == 'title') { for (var j = 1; j < p.length; j++) { var title = p[j].split('='); if (title.length != 2) continue; if (title[0] == 'set') settings.titleSet = title[1] == 'true'; else if (title[0] == 'enabled') settings.titleEnabled = title[1] == 'true'; else if (title[0] == 'delete') settings.titleDeleteRow = title[1] == 'row'; } } else if (p[0] == 'border') { for (var j = 1; j < p.length; j++) { var opt = p[j].split('='); if (opt.length != 2) continue; if (opt[0] == 'color') settings.borderColor = opt[1] - 0; else if (opt[0] == 'width') settings.borderWidth = opt[1] - 0; else if (opt[0] == 'enabled') settings.borderEnabled = opt[1] == 'true'; } } else if (p[0] == 'spacing') { for (var j = 1; j < p.length; j++) { var opt = p[j].split('='); if (opt.length != 2) continue; if (opt[0] == 'size') { settings.horizontalSpacing = opt[1] - 0; settings.verticalSpacing = opt[1] - 0; } else if (opt[0] == 'width') settings.horizontalSpacing = opt[1] - 0; else if (opt[0] == 'height') settings.verticalSpacing = opt[1] - 0; else if (opt[0] == 'enabled') settings.spacingEnabled = opt[1] == 'true'; } } } settings.quality = 85; settings.description.location = description; } function format(field, catalog) { if (catalog == indexCatalog) { indexModified = true; checkUpdateIndex(); } else { displayModified = true; checkUpdateDisplay(); } catalog.EditFormat(theSelection, 1, field); } function oncaption() { if (!window.dialogArguments && fImage.description.length && fImage.description == description.value) message('If you edit a caption in the Properties editor, any formatting you might have applied to the caption on the photo page is lost.', 'info', 'nof_qpgchangecaption', 8); } function applyToAll() { var sub = (currentTab1 ? '' : 'Tn'); getFromTab(); for (var i = 0; i < count; i++) { if (i == index) continue; selection.SetIndex(indices[i]); var image = selection.GetField('Image'); var rotation = selection.GetField('ImageRotation') - 0; var flags = selection.GetField('Image' + sub + 'Flags') - 0; var quality = selection.GetField('Image' + sub + 'Quality') - 0; var format = selection.GetField('Image' + sub + 'Format').toLowerCase(); if (format != currentImage.format || quality != currentImage.quality) { selection.SetField('Image' + sub + 'Quality', currentImage.quality); selection.SetField('Image' + sub + 'Format', currentImage.format); if ((flags & TABLE_GENERATED_MASK) != 0) { var width = selection.GetField('Image' + sub + 'Width') - 0; var height = selection.GetField('Image' + sub + 'Height') - 0; theSelection.FreeKey(image, width, height, rotation, quality, format); flags &= ~TABLE_GENERATED_MASK; selection.SetField('Image' + sub + 'Flags', flags); } } } selection.SetIndex(indices[index]); } function setImageSizeAll() { var sub = (currentTab == 2 ? '' : 'Tn'); getFromTab(); for (var i = 0; i < count; i++) { selection.SetIndex(indices[i]); var flags = selection.GetField('Image' + sub + 'Flags') - 0; if ((flags & TABLE_GENERATED_MASK) != 0) { var w = selection.GetField('Image' + sub + 'Width') - 0; var h = selection.GetField('Image' + sub + 'Height') - 0; var maxWidth = currentSettings.lsWidth; var maxHeight = currentSettings.lsHeight; if (w < h && currentSettings.ptWidth && currentSettings.ptHeight) { maxWidth = currentSettings.ptWidth; maxHeight = currentSettings.ptHeight; } var wscale = toint(1000 * w / maxWidth); var hscale = toint(1000 * h / maxHeight); var scale = (wscale > hscale ? wscale : hscale); if (scale != 1000) { var image = selection.GetField('Image'); var rotation = selection.GetField('ImageRotation') - 0; var quality = selection.GetField('Image' + sub + 'Quality') - 0; var format = selection.GetField('Image' + sub + 'Format').toLowerCase(); theSelection.FreeKey(image, w, h, rotation, quality, format); flags &= ~TABLE_GENERATED_MASK; selection.SetField('Image' + sub + 'Flags', flags); } if (i == index) { if (currentTab == 2) fDisplayImage.flags = flags; else fIndexImage.flags = flags; } } } selection.SetIndex(indices[index]); } function selectColor(o) { var color = app2.SelectNewColor(fIndexSettings.borderColor); if (color != 0xffffffff) { o.style.backgroundColor = color; fIndexSettings.borderColor = color; } } function updateBorderWidth() { var w = borderwidth.value - 0; if (isNaN(w)) w = 0; else if (w < 0) w = 0; else if (w > 1000) w = 1000; borderwidth.value = w; fIndexSettings.borderWidth = w; } function updateCellSpacing() { var w = cellspacing.value - 0; if (isNaN(w)) w = 0; else if (w < 0) w = 0; else if (w > 10000) w = 10000; cellspacing.value = w; fIndexSettings.horizontalSpacing = w; fIndexSettings.verticalSpacing = w; } function selectDisplayColor(o) { var color = app2.SelectNewColor(fDisplaySettings.borderColor); if (color != 0xffffffff) { o.style.backgroundColor = color; fDisplaySettings.borderColor = color; } } function updateDisplayBorderWidth() { var w = displayborderwidth.value - 0; if (isNaN(w)) w = 0; else if (w < 0) w = 0; else if (w > 1000) w = 1000; displayborderwidth.value = w; fDisplaySettings.borderWidth = w; } function helpFormat(o) { var oPopup = window.createPopup(); var oPopBody = oPopup.document.body; oPopBody.style.backgroundColor = "lightyellow"; oPopBody.style.border = "solid black 1px"; oPopBody.innerHTML = "<table cellpadding=\"10\" cellspacing=\"0\" border=\"0\" width=\"100%\" height=\"100%\"><tr><td><font face='MS Sans Serif' size='-2'><b>Note:</b> If you specify formats and they do not appear in the text, it could be caused by the text style definitions, usually the definition of the Body and Normal(P) tags in the SiteStyle. For example, if the Body tag defines the font size, that definition overrides any font size you specify in the Object Format dialog. You can get around this by choosing a SiteStyle that does not define the property you want to set, or by formatting the individual photo titles.</font></td></tr></table>"; oPopup.show(-150, 10, 300 * app2.LogPixelsX / 96, 135 * app2.LogPixelsY / 96, o); }